package kr.hkit.powerjava.chapter09.submit;
 
class BankAccount {
	String owner;
	String accountnum;
	int balance;
	int rate;
	
	public BankAccount(String owner, String accountnum, int balance, int rate) {
		this.owner = owner;
		this.accountnum = accountnum;
		this.balance = balance;
		this.rate = rate;
	}
	
	public BankAccount() {
		
	}
	
	public int deposit(int amount) {
		balance += amount;
		System.out.println(owner + "님이 "+ amount + "만원을 입금하였습니다.");
		return balance;
	} 
	
	public int withdraw(int amount) {
		balance -= amount;
		System.out.println(owner + "님이" + amount + "만원을 입금하였습니다.");
		return balance;
	}
	
	//예상이자율 현 잔고 금액을 1년 적금에 넣었을 시 예상 금액
	public double intersetRate() {
		rate = (int) (balance * 1.02);
		System.out.println("현 잔고 금액을 1년 적금에 불입시 예상 수익은 "+rate+"만원 입니다.");
		return rate;
	}

	@Override
	public String toString() {
		return "[예금주=" + owner + ", 계좌번호=" + accountnum
				+ ", 잔액=" + balance + ", 이자율=" + rate + "]";
	}
}


public class BankAccountTest {
	public static void main(String[] args) {
		
		BankAccount bank = new BankAccount("정우성","112-222-1234",450,2);
		System.out.println(bank);
		bank.deposit(100);
		System.out.println(bank);
		bank.withdraw(50);
		System.out.println(bank);
		bank.intersetRate();
	}
}
